package com.xiangty.write;

import com.xiangty.bean.CustTemp;
import com.xiangty.mapper.CustTempMapper;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component("custTempWrite")
@StepScope
public class CustTempWrite implements ItemWriter<CustTemp> {

    @Autowired
    private CustTempMapper custTempMapper;

    @Override
    public void write(List<? extends CustTemp> list) throws Exception {
        if (list == null) {
            System.out.println("-------------custTempWrite没有数据");
            return;
        }

        System.out.println("----------CustTempWrite开始  " + list.size());
        try {
            for (CustTemp custTemp : list) {
                custTempMapper.saveCustTemp(custTemp);
//                System.out.println("------线程【" + Thread.currentThread().getName() + "】-------" + custTemp.getCustNo());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
